<template>
  <div class="aaaa">
    <Common-Slider-Bar
      ref="silderBar"
      :item-view-option="{
        itemTitle: 'PROGRAMNAME',
        key: 'ID',
        menuTitle: 'PROGRAMNAME'
      }"
      :open-mune-children="openMuneChildren"
      :request="{
        url: url + '/dynamicReportForm/queryBodyByProduce',
        method: 'post',
        data: {
          pageIndex: 0,
          pageSize: 100,
          pageType: 1,
          tableId: 408,
          resultAsTree: true,
          filterList: [
            { col: 'ENTERPRISECODE', value: this.$route.query.ENTERPRISECODE },
            { col: 'ISCAPITAL', value: '是' },
            { col: 'YEAR', value: Year }
          ]
        }
      }"
      :search-key="'PROGRAMNAME'"
      @select="selectData"
      @fatherSelct="fatherSelct"
      @requestSuccess="requestSuccess"
    />
    <template
      slot="top"
    >
      <el-select
        v-model="projectAnalysisType"
        class="projectAnalysisType"
        @change="projectAnalysisTypeChange"
      >
        <el-option
          v-for="item in options"
          :key="item.value"
          :label="item.label"
          :value="item.value"
        />
      </el-select>
    </template>
  </div>
</template>

<script type="text/ecmascript-6">
import CommonSliderBar from '@/components/CommonSliderBar';
import baseUrl from '@/utils/processRequest1';

export default {
  components: { CommonSliderBar },
  props: {
    searchData: {
      typr: Object,
      default: () => {}
    }
  },
  data() {
    return {
      url: '',
      Year: '',
      openMuneChildren: false,
      xcRoleName: '',
      options: [{ value: 1, label: '项目类型' }, { value: 2, label: '条线' }],
      projectAnalysisType: 1
    };
  },
  created() {
    this.xcRoleName = localStorage.getItem('xcRoleName');
    this.init();
  },
  methods: {
    requestSuccess(obj) {
      const { data } = obj;
      console.log();
      data.length && this.$refs.silderBar.openKeys([data[0].ID]);
    },
    init() {
      baseUrl().then(res => {
        this.url = res.url;
        this.Year = localStorage.getItem('chooseYear');
        this.$nextTick(() => {
          this.$refs.silderBar.send();
        });
      });
    },
    selectData(val) {
      this.$emit('selectData', val);
    },
    fatherSelct(val) {
      this.$emit('fatherSelct', val);
    },
    projectAnalysisTypeChange(val) {
      this.$emit('projectAnalysisTypeChange', val);
    }
  }
};
</script>

<style lang="scss" scoped>
.aaaa {
  width: 100%;
  height: 100%;
  .projectAnalysisType {
      width: 90%;
      padding-left: 10%;
    }
}
</style>
